package com.example.springcode.test;

import com.example.springcode.beans.factory.DisposableBean;
import com.example.springcode.beans.factory.InitializingBean;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author: chenxiuxiang
 * @Date: 2024-03-04 19:07
 * @Description:
 */
public class UserDao implements InitializingBean, DisposableBean {
    private static final Map<String, String> HASH_MAP = new HashMap<>();

    public String queryUserName(String uId) {
        return HASH_MAP.get(uId);
    }

    @Override
    public void destroy() throws Exception {
        System.out.println("执行UserDao销毁方法");
        HASH_MAP.clear();
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println("执行UserDao初始化方法");
        HASH_MAP.put("10001", "Cxx");
        HASH_MAP.put("10002", "Cxx2");
        HASH_MAP.put("10003", "Cxx3");
    }
}
